﻿@model Sheng.WeixinConstruction.Infrastructure.RecommendUrlSettingsEntity

@{
    ViewBag.MainMenu = "Member";
    ViewBag.LeftMenu = "RecommendUrl";

    ViewBag.Title = "会员多级推广";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script language="javascript">


    $(document).ready(function () {

        if (_online == false)
            return;

        $("[keyenter]").keypress(function (e) {
            if (e.keyCode == 13) {
                save();
            }
        });

        _validator = $("#form").validate({
            onfocusout: false,
            onkeyup: false,
            showErrors: showValidationErrors,
            rules: {
                "txtAttentionPoint": {
                    required: true,
                    number: true,
                    digits: true,
                    range: [0, 10000]
                }
            },
            messages: {
                "txtAttentionPoint": {
                    required: "请输入每引导一个新会员奖励积分；",
                    number: "奖励积分请输入有效整数字；",
                    digits: "奖励积分请输入有效整数字；",
                    range: "奖励积分请介于 0 到 10000 之间；"
                }
            }
        });
    });

    function save() {
        if (_validator.form() == false) {
            return;
        }

        var loadLayerIndex = layer.load(0, {
            shade: [0.2, '#fff']
        });

        var args = new Object();
        args.AttentionPoint = $("#txtAttentionPoint").val();
        args.LandingUrl = $("#txtLandingUrl").val();

        var url = "/Api/RecommendUrl/SaveSettings";

        $.ajax({
            url: url,
            type: "POST",
            dataType: "json",
            data: JSON.stringify(args),
            success: function (data, status, jqXHR) {
                layer.close(loadLayerIndex);
                if (data.Success) {
                    layerAlert("保存成功，您的设置将在几分钟之内生效。");
                } else {
                    layerAlert(data.Message);
                }
            },
            error: function (xmlHttpRequest) {
                layer.close(loadLayerIndex);
                alert("Error: " + xmlHttpRequest.status);
            }
        });
    }

</script>



<div id="divContentTips">
    会员可以在会员中心生成一个唯一的推广链接地址，将其分享给好友，通过此链接地址关注的新会员，将成为其下线会员。<br />
    每引导一个新会员关注，都可以得到奖励积分。
</div>

<div class="divBaseSettings">
    <form id="form">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="200" height="50">每引导一个新会员奖励积分：</td>
                <td><input name="txtAttentionPoint" type="text" class="input_18" style="width:400px;" id="txtAttentionPoint" value="@Model.AttentionPoint" maxlength="10" /></td>
            </tr>
            <tr>
                <td height="50">推广链接落地页：</td>
                <td><input name="txtLandingUrl" type="text" class="input_18" style="width:400px;" id="txtLandingUrl" value="@Model.LandingUrl" maxlength="500" /></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <div class="font_gray_13" style="width:96%;margin-bottom:10px;">
                        如果不指定落地页，那么会员的推荐链接将转到公众号二维码页面。
                    </div>
                </td>
            </tr>
        </table>
    </form>
</div>


<div style=" margin-top:20px;">
    <input name="btnSave" type="button" class="btn_blue" id="btnSave" value="保 存" onclick="save()" />
</div>

